home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 3 / Amiga Tools 3.iso / rexx / rendertexturesis.tsrx < prev    next >
Text File  |  1995-04-17  |  4KB  |  190 lines

  1. /* TextureStudio ARexx script **************************************/
  2.  
  3. /* Allow commands to return results */
  4.  
  5. options results
  6.  
  7. /* On error, goto ERROR:. Comment out this line if you wish to */
  8. /* perform your own error checking. */
  9.  
  10. signal on error
  11.  
  12. /* BEGIN PROGRAM *************************************************/
  13.  
  14. address "TEXTURESTUDIO"
  15.  
  16. /* Filename extension used for render files */
  17.  
  18. FILENAME_EXTENSION = '.ilbm'
  19.  
  20.  
  21. /* Bring TextureStudio's screen to the front */
  22.  
  23. SCREEN_FRONT
  24.  
  25. /* Get the user's texture path */
  26.  
  27. TEXTUREPATH_GET VAR texture_path
  28.  
  29. /* Get the user's renderscreen path */
  30.  
  31. RENDERSCREENPATH_GET VAR renderscreen_path
  32.  
  33. /* Display multiselect file requester to select texture modules */
  34.  
  35. REQUEST_MULTIFILE PATHPART '"'texture_path'"' PATTERN '"#?.itx"',
  36.     TITLE '"Select texture file(s)"' STEM 'selected.'
  37.  
  38. /* Request a destination path for renderscreen files */
  39.  
  40. REQUEST_DIR PATHPART '"'renderscreen_path'"' TITLE '"Select a destination dir"',
  41.     VAR 'dest_path'
  42.  
  43.  
  44. /* Stop input to windows */
  45.  
  46. GUI_BLOCK
  47.  
  48. /* Loop through each selected texture file and render to screen using current */
  49. /* user settings, then save out to selected path */
  50.  
  51. do c = 0 to (selected.files.count - 1)
  52.  
  53.     /* Open texture and flush out all others */
  54.  
  55.     OPEN selected.files.c FLUSH
  56.  
  57.     /* Split source file into filepart and pathpart */
  58.  
  59.     FILE_SPLIT '"'selected.files.c'"' stem 'texture.'
  60.  
  61.     /* Chop off file extension */
  62.     /* e.g. Radar.itx -> Radar */
  63.  
  64.     parse var texture.filepart texture_name '.'
  65.  
  66.     dest_filepart = texture_name
  67.  
  68.     /* Join destination file onto destination path */
  69.  
  70.     FILE_JOIN PATHPART '"'dest_path'"' FILEPART '"'dest_filepart'"',
  71.         VAR 'dest_file'
  72.  
  73.     /* Render to file as ilbm24 */
  74.  
  75.     PREFS_SET FILEFORMAT ILBM24
  76.  
  77.     RENDEROPTIONS_SET TOFILE 1 FILE '"'dest_file'"'
  78.  
  79.     /* Render to screen and file */
  80.  
  81.     RENDER TOBACK
  82.  
  83.     /* Address ImageStudio */
  84.  
  85.     address "IMAGESTUDIO"
  86.  
  87.     /* Open in file */
  88.  
  89.     OPEN '"'dest_file'"'
  90.  
  91.     /* Delete orginal file */
  92.  
  93.     address command 'delete <NIL: >NIL: "'||dest_file||'"'
  94.  
  95.     /* Put filename extension onto texture name */
  96.     /* e.g. Radar -> Radar.ilbm */
  97.  
  98.     dest_filepart = texture_name||FILENAME_EXTENSION
  99.  
  100.     FILE_JOIN PATHPART '"'dest_path'"' FILEPART '"'dest_filepart'"',
  101.         VAR 'dest_file'
  102.  
  103.     /* Reduce to 32 colours with dithering */
  104.  
  105.     COLOURS 32 DITHER "FS"
  106.  
  107.     /* Save as ilbm */
  108.  
  109.     SAVE '"'dest_file'"' FORCE
  110.  
  111.     /* Back to TextureStudio */
  112.  
  113.     address "TEXTURESTUDIO"
  114.     
  115. end
  116.  
  117. /* Unblock the windows now */
  118.  
  119. GUI_UNBLOCK
  120.  
  121.  
  122. /* END PROGRAM ***************************************************/
  123.  
  124. exit
  125.  
  126. /* On ERROR */
  127.  
  128. ERROR:
  129.  
  130. /* If we get here, either an error occurred with the command's */
  131. /* execution or there was an error with the command itself. */
  132. /* In the former case, rc2 contains the error message and in */
  133. /* the latter, rc2 contains an error number. SIGL contains */
  134. /* the line number of the command which caused the jump */
  135. /* to ERROR: */
  136.  
  137. if datatype(rc2,'NUMERIC') == 1 then do
  138.     /* See if we can describe the error with a string */
  139.  
  140.     select
  141.         when rc2 == 103 then
  142.             err_string = "ERROR 103, "||,
  143.                 "out of memory at line "||SIGL
  144.         when rc2 == 114 then
  145.             err_string = "ERROR 114, "||,
  146.                 "bad command template at line "||SIGL
  147.         when rc2 == 115 then
  148.             err_string = "ERROR 115, "||,
  149.                 "bad number for /N argument at line "||SIGL
  150.         when rc2 == 116 then
  151.             err_string = "ERROR 116, "||,
  152.                 "required argument missing at line "||SIGL
  153.         when rc2 == 117 then
  154.             err_string = "ERROR 117, "||,
  155.                 "value after keywork missing at line "||SIGL
  156.         when rc2 == 118 then
  157.             err_string = "ERROR 118, "||,
  158.                 "wrong number of arguments at line "||SIGL
  159.         when rc2 == 119 then
  160.             err_string = "ERROR 119, "||,
  161.                 "unmatched quotes at line "||SIGL
  162.         when rc2 == 120 then
  163.             err_string = "ERROR 120, "||,
  164.                 "line too long at line "||SIGL
  165.         when rc2 == 236 then
  166.             err_string = "ERROR 236, "||,
  167.                 "unknown command at line "||SIGL
  168.         otherwise
  169.             err_string = "ERROR "||rc2||" at line "||SIGL
  170.         end
  171.         end
  172. else if rc2 == 'RC2' then do
  173.     err_string = "ERROR in command at line "||SIGL
  174.     end
  175. else do
  176.         err_string = rc2||", line "||SIGL
  177.         end
  178.  
  179. say err_string
  180.  
  181.  
  182. /* Unblock windows, just incase they are still blocked by the program being */
  183. /* terminated mid-way */
  184.  
  185. address "TEXTURESTUDIO"
  186.  
  187. GUI_UNBLOCK
  188.  
  189. exit
  190.